import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'LPRCamera.dart';
import 'faceCamera.dart';

///添加设备
class AddDevice extends StatefulWidget {
  @override
  _AddDeviceState createState() => _AddDeviceState();
}

class _AddDeviceState extends State<AddDevice>
    with SingleTickerProviderStateMixin {
  TabController? _tabController;
  List tabs = ["人脸", "车牌"];

  Widget _buildDrawerChild(context) => ListView(
        children: [
          DrawerHeader(
            decoration: BoxDecoration(
              image: DecorationImage(
                  image: AssetImage("assets/images/blue_sky.jpg"),
                  fit: BoxFit.cover),
            ),
            child: Text(""),
          ),
          ListTile(
            leading: Icon(Icons.camera_front_rounded),
            title: Text(
              "人脸识别",
              style: TextStyle(
                fontSize: 25,
                fontWeight: FontWeight.bold,
              ),
            ),
            trailing: Icon(Icons.chevron_right),
            onTap: () {
              Navigator.of(context).pop();
              Navigator.of(context).push(
                  MaterialPageRoute(builder: (context) => AddFaceCamera()));
            },
          ),
          Divider(),
          ListTile(
            leading: Icon(
              Icons.car_repair_sharp,
            ),
            title: Text(
              "车牌识别",
              style: TextStyle(
                fontSize: 25,
                fontWeight: FontWeight.bold,
              ),
            ),
            trailing: Icon(Icons.chevron_right),
            onTap: () {
              Navigator.of(context).pop();
              Navigator.of(context).push(
                  MaterialPageRoute(builder: (context) => AddLPRCamera()));
            },
          ),
          Divider(),
        ],
      );

  @override
  void initState() {
    super.initState();
    SystemChrome.setEnabledSystemUIOverlays([]);
    _tabController = TabController(length: tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("添加设备"),
        bottom: TabBar(
          labelStyle: TextStyle(fontSize: 20),
          controller: _tabController,
          tabs: tabs
              .map((e) => Tab(
                    text: e,
                  ))
              .toList(),
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: [
          AddFaceCamera(),
          AddLPRCamera(),
        ],
      ),
    );
  }
}
